﻿@{
    ViewData["Title"] = "组织管理";
}
<div class="layui-layout layui-layout-admin">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="" lay-filter="val-filter">
                <div class="layui-form-item">
                    <label class="layui-form-label">上级</label>
                    <div class="layui-input-block">
                        <input type="text" name="folder" id="folder" lay-filter="folder" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="id" value="0">
                        <input type="hidden" name="pid" id="pid" value="0">
                        <input type="text" name="name" autocomplete="off" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="type" value="0" title="文件" checked>
                        <input type="radio" name="type" value="1" title="文件夹">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" class="layui-textarea"></textarea>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

@section scripts {
    <script type="text/javascript">
        var app = {};
        layui.use(['http', 'treeSelect'], function () {
            var $ = layui.$,
                form = layui.form,
                treeSelect = layui.treeSelect,
                http = layui.http;
            //
            app.initData = function () {
                treeSelect.render({
                    elem: '#folder',
                    data: '/api/sysCustomForm/list',
                    headers: {
                        Authorization: http.getToken()
                    },
                    click: function (d) {
                        $('#pid').val(d.current.id);
                    }
                });
            };
            app.save = function (callback) {
                var data = form.val('val-filter');
                var url = '/api/sysCustomForm/add';
                return http.post(url, data);
            }
        })
    </script>
}
